﻿using System;

namespace IOP.OpenType
{
    /// <summary>
    /// 时间
    /// </summary>
    public readonly struct LONGDATETIME
    {
        /// <summary>
        /// 起始时间
        /// </summary>
        public static readonly DateTime Start = new DateTime(1904, 1, 1, 0, 0, 0);

        private readonly long origin;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="number"></param>
        public LONGDATETIME(long number) => origin = number;

        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="time"></param>
        public static implicit operator DateTime(LONGDATETIME time) => Start.AddSeconds(time.origin);
        /// <summary>
        /// 隐式转换
        /// </summary>
        /// <param name="seconds"></param>
        public static implicit operator LONGDATETIME(long seconds) => new LONGDATETIME(seconds);
    }
}
